/*
P4.login(
	{
		server:"tw-p4proxy:1667",
		workspace:"default.al_siao.SMEX-Lead",
		account:"al_siao",
		password:"Notepad++"
	},
	{
	}
	,
	null

);*/
function check(){
	$("#browser").empty();
	var callbacker=
		{
			onGetNewStep:function(newStepInfo){

				var node = $("<li class='folder task'><div class='time'>Checking </div> <span class='title'>"+newStepInfo.title+"</span></li>").appendTo("#browser");
				node.newStepInfo=newStepInfo;
				$("#browser").treeview({
					add: node
				});
				newStepInfo.node=node;
				
				var progressMessage = $("<li class='file progressMessage'></li>").appendTo(node);
				$(node).treeview({
					add: progressMessage
				});
				newStepInfo.progressMessage=progressMessage;

			
				/*var stepElement=$('<div></div>');
				newStepInfo.stepElement=stepElement;
				{
					var titleElement=$('<h3>'+newStepInfo.title+'</h3>');
					newStepInfo.titleElement=titleElement;
					stepElement.append(titleElement);
					
					var contentElement=$('<div></div>');
					newStepInfo.contentElement=contentElement;
					stepElement.append(contentElement);	
				}
				$("#accordion").append(stepElement);*/
				
				newStepInfo.onProgressMessage=function(msg){
					//$("#accordion").append('<div><p>progress:'+msg+'</p></div>');
					$(this.progressMessage).text(msg);
				};
				
				newStepInfo.onFinish=function(param){
					$(this.progressMessage).remove();
					//$('<div>'+this.time.toLocaleDateString()+' '+this.time.toLocaleTimeString()+'</div>').appendTo(this.stepElement);
					$(this.node).addClass(param.isSuccess?'taskSuccess':'taskFail')
					$(this.node).children('.title').text(this.title);
					$(this.node).children('.time').text(this.time.toLocaleDateString()+' '+this.time.toLocaleTimeString());
					
				};

			},
			onException:function(e){
				alert(getDumpObjString(e,0).join('\n'))
			}
		};

	var w=showModelessDialog('AsynWindow.htm',
		{
			callbacker:callbacker,
			filePath:$('#input').attr("value")//"//Corp/OSCE_common/Dev/OSCE_common-11.2/OSCE_common/src/Client/PccNT/Service/CNTTmListen/cnttmlis_Service.cpp#59"
		}		
		,'dialogWidth:100px;dialogHeight:100px;status:0');
		
	w.opener=window;

}
function main(){
	
	//$("#accordion").accordion();
	$("#browser").treeview();
	$("#check").click(check);
	window.resizeTo(600,600);
}
main();

/*
handleStep(new P4Step(
	P4Path.fromPath("//SMB/CSM/Dev/CSM-6.0/CSM/installshield/ServerSetup/Setup Files/Compressed Files/Language Independent/Intel 32/upg3002311.INI#7")
));*/

/*
$(function() {
	$("#dialog").dialog({
		bgiframe: true,
		height: 140,
		modal: true
	});
	
	$("#dialog").toggle('clip',0,500);
	
	$("#button").click(function() {
		$("#dialog").toggle('clip',0,500);
		return false;
	});	
});
*/

function showResult(){
	//event.dataTransfer.effectAllowed='copy';
	event.dataTransfer.dropEffect='copy';
	
	$('#accordion').append
	(
		'<div>'+
		getDumpObjString
		(
			{
				type:event.type,
				data:event.dataTransfer.getData('Text'),
				dropEffect:event.dataTransfer.dropEffect
			}
			,0
		).join('\n')+'</div>'
	);
	//alert(getDumpObjString(event,0).join('\n'));
}